#include "DeviceInput.h"

#include "../DebugUtility/DebugOutputString.h"
#include <dinput.h>

DeviceInput::DeviceInput(){}
DeviceInput::~DeviceInput(){}

DeviceInput* DeviceInput::getInst()
{
	static DeviceInput d;
	return &d;
}

void DeviceInput::InputInit()
{
	HINSTANCE hInst = GetModuleHandle(NULL);

	HDC glDc = wglGetCurrentDC();
	HWND hWnd = WindowFromDC(glDc);

	_keyboad.keyboadInit(hInst, hWnd);
	_joystick.JoyStickInit(hInst, hWnd);
	_mouse.mouseInit(hInst, hWnd);
}

void DeviceInput::Update()
{
	_keyboad.keyboadUpdate();
	_joystick.JoyStickUpdate();
	_mouse.mouseUpdate();
}

void DeviceInput::Release()
{
	_keyboad.keyboadFinish();
	_joystick.JoyStickFinish();
	_mouse.mouseFinish();
}

bool DeviceInput::isKeyState(KeyCode::Code code)
{
	return _keyboad.isKeyState(code);
}

bool DeviceInput::isKeyTrigger(KeyCode::Code code)
{
	return _keyboad.isKeyTrigger(code);
}

bool DeviceInput::isJoyState(JoyCode::Code code, int joyNum)
{
	return _joystick.isJoyState(code, joyNum);
}

bool DeviceInput::isJoyTrigger(JoyCode::Code code, int joyNum)
{
	return _joystick.isJoyTrigger(code, joyNum);
}

void DeviceInput::getJoyAxis(int joyNum, int* x, int* y, int* z)
{
	_joystick.getAxis(joyNum, x, y, z);
}